﻿@using Seal.Model
@using Seal.Helpers
@{
    Report report = Model;
    ReportView view = report.CurrentView;
    Repository repository = report.Repository;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='shortcut icon' href='@report.AttachImageFile("favicon.ico")' type='image/x-icon' />
    <title>
        @report.ExecutionName
    </title>

    <!--CSS-->
    @Raw(report.AttachCSSFile("datatables.min.css", report.GenerateHTMLDisplay && report.ExecutionContext == ReportExecutionContext.DesignerReport ? "" : "https://cdn.datatables.net/v/bs-3.3.7/jq-3.3.1/dt-1.10.20/b-1.6.1/fc-3.3.0/fh-3.1.6/r-2.2.3/sc-2.0.1/sl-1.3.1/datatables.min.css"))
    @Raw(report.AttachCSSFile("bootstrap-select.min.css", "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css"))
    @Raw(report.AttachCSSFile("bootstrap-datetimepicker.min.css"))

    @Raw(report.AttachCSSFiles(repository.Configuration.CssFiles))
    @Raw(report.AttachCSSFile("seal.css"))

    <!--Scripts-->
    @Raw(report.AttachScriptFile("datatables.min.js", "https://cdn.datatables.net/v/bs-3.3.7/jq-3.3.1/dt-1.10.20/b-1.6.1/fc-3.3.0/fh-3.1.6/r-2.2.3/sc-2.0.1/sl-1.3.1/datatables.min.js"))
    @Raw(report.AttachScriptFile("bootstrap-select.min.js", "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"))
    @Raw(report.AttachScriptFile("moment.min.js"))
    @if (view.CultureInfo.TwoLetterISOLanguageName != "en")
    {
        @Raw(report.AttachScriptFile("i18n\\moment." + view.CultureInfo.TwoLetterISOLanguageName + ".js"))
        @Raw(report.AttachScriptFile("i18n\\selectpicker." + view.CultureInfo.TwoLetterISOLanguageName + ".min.js"))
    }
    @Raw(report.AttachScriptFile("bootstrap-datetimepicker.min.js"))

    @Raw(report.AttachScriptFile("datetime-moment.js"))
    @if (report.HasChart)
    {
        @Raw(report.AttachScriptFile("d3.min.js"))
        @Raw(report.AttachScriptFile("d3-time.v1.min.js", "https://d3js.org/d3-time.v1.min.js"))
        @Raw(report.AttachScriptFile("d3-time-format.v2.min.js", "https://d3js.org/d3-time-format.v2.min.js"))
        @Raw(report.AttachScriptFile("d3\\" + view.CultureInfo.TwoLetterISOLanguageName + ".js"))
    }

    @if (report.HasChartJSChart)
    {
        @Raw(report.AttachScriptFile("Chart.min.js", "https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"))
    }

    @if (report.HasPlotlyChart)
    {
        @Raw(report.AttachScriptFile("plotly-latest.min.js", "https://cdn.plot.ly/plotly-1.48.1.min.js"))
        if (view.CultureInfo.TwoLetterISOLanguageName != "en")
        {
            @Raw(report.AttachScriptFile("plotly\\plotly-locale-" + view.CultureInfo.TwoLetterISOLanguageName + ".js"))
        }
    }

    @if (report.HasNVD3Chart)
    {
        @Raw(report.AttachScriptFile("nv.d3.min.js"))
        @Raw(report.AttachCSSFile("nv.d3.min.css"))
        <script>
                function nvd3TranslateText(text)
                {
                    @foreach (var translation in repository.NVD3Translations)
                    {
                    <text>if (text == '@Raw(Helper.ToJS(translation.Key))') return '@Raw(Helper.ToJS(translation.Value))';</text>
                    }
                    return text;
                }
        </script>
        @Raw(report.AttachScriptFile("chartNVD3.js"))
    }
    @Raw(report.AttachScriptFiles(repository.Configuration.ScriptFiles))

    <script type="text/javascript">
        var inReport = true;
        var generateHTMLDisplay =  @Helper.ToJS(report.GenerateHTMLDisplay);

        var urlPrefix = "@report.WebUrl";
        var executionGUID = "@report.ExecutionGUID";
        var executionTimer = null;
        var refreshTimer = null;
        var refreshRate = @view.GetNumericValue("refresh_rate");
        var hasRestrictions = @Helper.ToJS(report.HasRestrictions);
        var showRestrictions = @Helper.ToJS(report.HasRestrictions && view.GetBoolValue("restriction_button"));
        var hasNavigation = @Helper.ToJS(report.HasNavigation && (report.IsNavigating || report.GenerateHTMLDisplay));/*SRKW do not modify*/
        var forceExecution = @Helper.ToJS(view.GetBoolValue(Parameter.ForceExecutionParameter) || report.HasNavigation);
        var isExecuting = @Helper.ToJS(report.IsExecuting);
        var isCancel = @Helper.ToJS(report.Cancel);
        var printLayout = @Helper.ToJS(report.PrintLayout);
        var showMsgDuringExec = @Helper.ToJS(view.GetValue("messages_mode")== "enabledshownexec");
        var autoscroll = false;

        var rootViewId = '@view.ViewId';

        //text
        var messagesText = '@report.Translate("Messages")';
        var startingExecText = '@report.Translate("Starting execution...")';
        var cancelText = '@report.Translate("Cancel")';

        //formats
        var languageName = '@view.CultureInfo.TwoLetterISOLanguageName';
        var decimalSeparator = '@Raw(view.CultureInfo.NumberFormat.NumberDecimalSeparator)';
        var shortDateFormat = '@Raw(repository.MomentJSShortDateFormat)';
        var shortDateTimeFormat = '@Raw(repository.MomentJSShortDateTimeFormat)';
        var thousandSeparator = '@Raw(Helper.ToJS(view.CultureInfo.NumberFormat.NumberGroupSeparator))';
        var currencySymbol = '@Raw(Helper.ToJS(view.CultureInfo.NumberFormat.CurrencySymbol))';

        var dtTooltips = {
            today: '@Raw(report.TranslateToJS("Go to today")))',
            clear: '@Raw(report.TranslateToJS("Clear selection"))',
            close: '@Raw(report.TranslateToJS("Close"))',
            selectMonth: '@Raw(report.TranslateToJS("Select Month"))',
            prevMonth: '@Raw(report.TranslateToJS("Previous Month"))',
            nextMonth: '@Raw(report.TranslateToJS("Next Month"))',
            selectYear: '@Raw(report.TranslateToJS("Select Year"))',
            prevYear: '@Raw(report.TranslateToJS("Previous Year"))',
            nextYear: '@Raw(report.TranslateToJS("Next Year"))',
            selectDecade: '@Raw(report.TranslateToJS("Select Decade"))',
            prevDecade: '@Raw(report.TranslateToJS("Previous Decade"))',
            nextDecade: '@Raw(report.TranslateToJS("Next Decade"))',
            prevCentury: '@Raw(report.TranslateToJS("Previous Century"))',
            nextCentury: '@Raw(report.TranslateToJS("Next Century"))',
            pickHour: '@Raw(report.TranslateToJS("Pick Hour"))',
            incrementHour: '@Raw(report.TranslateToJS("Increment"))',
            decrementHour: '@Raw(report.TranslateToJS("Decrement"))',
            pickMinute: '@Raw(report.TranslateToJS("Pick Minute"))',
            incrementMinute: '@Raw(report.TranslateToJS("Increment"))',
            decrementMinute: '@Raw(report.TranslateToJS("Decrement"))',
            pickSecond: '@Raw(report.TranslateToJS("Pick Second"))',
            incrementSecond: '@Raw(report.TranslateToJS("Increment"))',
            decrementSecond: '@Raw(report.TranslateToJS("Decrement"))',
            togglePeriod: '@Raw(report.TranslateToJS("Toggle Period"))',
            selectTime: '@Raw(report.TranslateToJS("Select Time"))'
        };

        function redrawDashboard() { }

        $.fn.dataTable.moment(shortDateFormat);
        $.fn.dataTable.moment(shortDateTimeFormat);
        $.extend( true, $.fn.dataTable.defaults, {
            responsive: {
                details: {
                    renderer: function (api, rowIdx, columns) {
                        return dtRenderer(api, rowIdx, columns);
                    }
                }
            },
            columnDefs: [
                { orderable: false, targets: ["firstcell"]},
                {
                    targets: "_all",
                    createdCell: function (td, cellData, rowData, row, col) {
                        dtCreatedCell(td, cellData, rowData, row, col);
                    }
                }
            ],
            language: {
                decimal: decimalSeparator,
                thousands: thousandSeparator,
                processing: "@report.Translate("Processing...")",
                lengthMenu: "@report.Translate("Show _MENU_ rows")",
                zeroRecords: "@report.Translate("No rows")",
                emptyTable: "@report.Translate("No records")",
                info: "@report.Translate("Showing _START_ to _END_ of _TOTAL_")",
                infoEmpty: "@report.Translate("Showing 0 to 0 of 0")",
                infoFiltered: "@report.Translate("(filtered from _MAX_)")",
                infoPostFix: "",
                search: "@report.Translate("Filter:")",
                paginate: {
                    first: "|&lt;",
                    previous: "&lt;&lt;",
                    next: ">>",
                    last: ">|"
                }
            },
            pagingType: "full_numbers",
            autoWidth: false,
            stateSave: @Helper.ToJS(!string.IsNullOrEmpty(report.WebUrl)),
            stateSaveCallback: function(settings,data) {
                try {
                    (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
                        'DataTables_'+settings.sInstance+'_Result',
                        JSON.stringify( data ));
                } catch (e) {}
            },
            stateLoadCallback: function(settings) {
                try {
                    return JSON.parse(
                        (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
                            'DataTables_'+settings.sInstance+'_Result'
                        ));
                } catch (e) {}
            }
    });
    </script>
    @Raw(report.AttachScriptFile("helpers.js"))
    @Raw(report.AttachScriptFile("common.js"))
    @Raw(report.AttachScriptFile("custom.js"))
    <script>
            @Raw(view.GetValue("additional_js"))
    </script>
    <style>
            @Raw(view.GetValue("additional_css"))
    </style>
</head>
<body>
    @Include(view.GetPartialTemplateKey("Report.iHeader", view), view)

    <div id="main_container" class="container@(view.GetBoolValue("container_fluid") ? "-fluid" : "")" style="display:none;">
        @if (report.GenerateHTMLDisplay && !report.PrintLayout && view.GetValue("restrictions_position") == "right")
        {
            <div class="row">
                <div id="content_div" class="col-md-@(12-view.GetNumericValue("restrictions_width"))" classori="col-md-@(12-view.GetNumericValue("restrictions_width"))">
                    @Include(view.GetPartialTemplateKey("Report.iContent", view), view)
                </div>
                <div id="restrictions_div" class="collapse @(view.GetBoolValue("restriction_button") ? "in": "") col-md-@view.GetNumericValue("restrictions_width")">
                    @Include(view.GetPartialTemplateKey("Report.iRestrictions", view), view)
                </div>
            </div>
        }
        else if (report.GenerateHTMLDisplay && !report.PrintLayout && view.GetValue("restrictions_position") == "left")
        {
            <div class="row">
                <div id="restrictions_div" class="collapse @(view.GetBoolValue("restriction_button") ? "in": "") col-md-@view.GetNumericValue("restrictions_width")">
                    @Include(view.GetPartialTemplateKey("Report.iRestrictions", view), view)
                </div>
                <div id="content_div" class="col-md-@(12-view.GetNumericValue("restrictions_width"))" classori="col-md-@(12-view.GetNumericValue("restrictions_width"))">
                    @Include(view.GetPartialTemplateKey("Report.iContent", view), view)
                </div>
            </div>
        }
        else
        {
            <div id="restrictions_div" class="collapse @(view.GetBoolValue("restriction_button") ? "in": "")">
                @Include(view.GetPartialTemplateKey("Report.iRestrictions", view), view)
            </div>
            <div>
                @Include(view.GetPartialTemplateKey("Report.iContent", view), view)
            </div>
        }
    </div>
    <!--back to top-->
    <a id="back-to-top" href="#" class="btn btn-warning btn-lg back-to-top" role="button" title="@report.Translate("Back to top")" data-toggle="tooltip" data-placement="top">
        <span>&#916;</span>
        <span id="back-to-top-close" style="top:0px;right:4px;font-size:14px;position:absolute;">&times;</span>
    </a>
</body>
</html>
